﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LX.Web.Excel;
using S4Store.Domain.AfterSaleKpi;

namespace S4Store.Domain.AfterSaleReport
{
    public class CarDecoReport: ExportObject
    {

        #region 数据导出
        public override bool? Discriminate(string propertyname)
        {
            if (propertyname == "ZHXSJDC")
            {
                return this.ZHXSJDC >= 0;
            }
            if (propertyname == "ZHYPXSLCY")
            {
                return this.ZHYPXSLCY >= 0;
            }
            if (propertyname == "DCZHJECY")
            {
                return this.DCZHJECY >= 0;
            }
            if (propertyname == "YHCPXSJDC")
            {
                return this.YHCPXSJDC >= 0;
            }
            if (propertyname == "YHCPXSLCY")
            {
                return this.YHCPXSLCY >= 0;
            }
            if (propertyname == "DCYHCPECY")
            {
                return this.DCYHCPECY >= 0;
            }
            return null;
        }
        #endregion


        public int Year { get; set; }
        public int Month { get; set; }
        public int Day { get; set; }
        public List<AfterSaleCarDecoratingMonthConfig> M { get; set; }
        public List<AfterSaleCarDecoratingDayInput> D { get; set; }
        public Store Store { get; set; }

        protected bool showlastday = false;
        public virtual void ShowLastDay(bool value)
        {
            showlastday = value;
        }

        [Export("车型")]
        public string CarBrand
        {
            get;
            set;
        }


        [Export("装潢率目标", Format="{0}%")]
        public decimal ZHLMB
        {
            get
            {
                return M.Sum(O => O.ZHLMB_DecoratingTargetRate);
            }
        }

        [Export("装潢额目标")]
        public decimal ZHEMB
        {
            get
            {
                return M.Sum(O => O.ZHEMB_DecoratingTargetValume);
            }
        }

        [Export("目标单车装潢销售额")]
        public decimal MBDCZHXSE
        {
            get
            {
                return M.Sum(O => O.MBDCZHE_DecoratingTargetValumeOnUnitCar);
            }
        }

        [Export("本月交车累计")]
        public int BYJCLJ
        {
            get
            {
                return D.Sum(O => O.JCTC_SaleCarNum);
            }
        }

        [Export("累计装潢销售台次")]
        public int LJZHXSTC
        {
            get {
                return D.Sum(O => O.ZHXSTC_DecoratingSaleCarNum);
            }
        }

        [Export("累计装潢销售总额")]
        public decimal LJZHXSZE
        {
            get {
                return D.Sum(O => O.ZHXSZE_DecoratingSalesTotalVolume);
            }
        }

        [Export("装潢销售进度", Format="{0}%")]
        public decimal ZHXSJD
        {
            get
            {
                if (ZHEMB == 0) return 0;
                return LJZHXSZE / ZHEMB * 100;
            }
        }

        [Export("装潢销售进度差", Format="{0}%", BackBround= ExcelCellBg.Warning)]
        public decimal ZHXSJDC
        {
            get
            {
                if (ZHXSJD == 0) return 0;
                return ZHXSJD - 100;
            }
        }

        [Export("装潢用品销售率", Format="{0}%")]
        public decimal ZHYPXSL
        {
            get {
                if (BYJCLJ == 0) return 0;
                return (decimal)LJZHXSTC / (decimal)BYJCLJ * 100;
            }
        }

        [Export("装潢用品销售率差异", Format="{0}%")]
        public decimal ZHYPXSLCY
        {
            get {
                return ZHYPXSL-ZHLMB;
            }
        }

        [Export("平均单车装潢销售额")]
        public decimal PJDCZHXSE
        {
            get {
                if(LJZHXSTC==0) return 0;
                return LJZHXSZE/(decimal)LJZHXSTC;
            }
        }

        [Export("单车装潢金额差异")]
        public decimal DCZHJECY
        {
            get {
                return PJDCZHXSE-MBDCZHXSE;
            }
        }

        [Export("养护产品销售率目标", Format = "{0}%")]
        public decimal YHCPXSLMB
        {
            get
            {
                return M.Sum(O => O.YHCPXSLMB_SaleMaintenanceTargetRate);
            }
        }

        [Export("养护产品销售额目标")]
        public decimal YHCPXSEMB
        {
            get
            {
                return M.Sum(O => O.YHCPXSEMB_SaleMaintenanceTargetValume);
            }
        }

        [Export("目标养护产品单车销售额")]
        public decimal MBYHCPDCXSE
        {
            get
            {
                return M.Sum(O => O.YHCPDCXSE_SaleMaintenanceTargetValumeOnUnitCar);
            }
        }

        [Export("累计养护产品销售台次")]
        public int LJYHCPXSTC
        {
            get
            {
                return D.Sum(o => o.YHCPXSTC_MaintenceSaleNum);
            }
        }

        [Export("累计养护产品销售总额")]
        public decimal LJYHCPXSZE
        {
            get
            {
                return D.Sum(o => o.YHCPXSZE_MaintenceSaleTotalVolume);
            }
        }




        [Export("养护产品销售进度", Format = "{0}%")]
        public decimal YHCPXSJD
        {
            get
            {
                if (YHCPXSEMB == 0) return 0;
                return LJYHCPXSZE / YHCPXSEMB * 100;
            }
        }

        [Export("养护产品销售进度差", Format = "{0}%", BackBround = ExcelCellBg.Warning)]
        public decimal YHCPXSJDC
        {
            get
            {
                if (YHCPXSJD == 0) return 0;
                return YHCPXSJD - 100;
            }
        }

        [Export("养护产品销售率", Format = "{0}%")]
        public decimal YHCPXSL
        {
            get
            {
                if (BYJCLJ == 0) return 0;
                return (decimal)LJYHCPXSTC / (decimal)BYJCLJ * 100;
            }
        }

        [Export("养护产品销售率差异", Format = "{0}%")]
        public decimal YHCPXSLCY
        {
            get
            {
                return YHCPXSL - YHCPXSLMB;
            }
        }

        [Export("平均单车养护产品额")]
        public decimal PJDCYHCPE
        {
            get
            {
                if (LJYHCPXSTC == 0) return 0;
                return LJYHCPXSZE / (decimal)LJYHCPXSTC;
            }
        }

        [Export("单车养护产品额差异")]
        public decimal DCYHCPECY
        {
            get
            {
                return PJDCYHCPE - MBYHCPDCXSE;
            }
        }



    }
}
